<%@ LANGUAGE="VBSCRIPT" %>
<%'  ------------------------------------------------------------
  '  propcontent.asp 
  '  ------------------------------------------------------------
  '  VCS INFO:
  '  
  '  $Revision:   1.37  $
  '  $Date:   19 Nov 1999 11:40:54  $
  '  $Author:   shsieh  $
  '  $Workfile:   propcontent.asp  $
  '  ------------------------------------------------------------
  '  All Rights Reserved.  Copyright (c) 1988-1998 FileNET Corp.
  '  ------------------------------------------------------------
  '%>
<!-- #include file="islogon.asp" -->
<!-- #include file="jscriptfix.asp" -->

<%
'NOTE: This page is for Image Services only.


'When DebugFlag is set to 1, this page displays more Property/Property Description
'information for debugging purposes.
DebugFlag = 0

'This page can be used for Folder or Document, depending on the Type value passed in.
'For folder, the Ident is the folder's pathname.
'For document, the Ident is the document's ID.
ObjType = CInt(Request.QueryString("Type"))
Ident = Request.QueryString("Ident")

'This is used to indicate whether it's an update operation or just a validation operation.
Update = Request.QueryString("Update")
'Indicate the status of the update or validation.
Status = Request.QueryString("Status")

'This session variable is used to keep track of whether the user prefers to display
'peoperty value hints during this session.
ShowHintsFlag = Session("ShowHints")


'Panagon IDM Web application uses the Session variable LibraryLogonID to keep track of
'whether the user has logged on.
'Please see logoncall.asp to see how the Session variable LibraryLogonID is set.
LibraryLogonID = Session("LibraryLogonID")
set LibraryObj = Server.CreateObject("IDMObjects.Library")
LibraryObj.LogonID = LibraryLogonID


'This is a utility function to convert the Security permission to a readable string.
Function ConvertPermissionLabel(ID)
    select case ID
        case Application("idmISAccessRead")
            s = "Read Access"
        case Application("idmISAccessWrite")
            s = "Write Access"
        case Application("idmISAccessAX")
            s = "Append/Execute Access"
    end select
    ConvertPermissionLabel = s
End Function

'This is a utility function to convert the Property Description to a useful hint
'for display.
Function ConvertToHints(ObjType, Prop)
    set PropDesc = Prop.PropertyDescription
           
    DataType = PropDesc.TypeID
    select case DataType
        case Application("idmTypeShort")
            s = "short"
        case Application("idmTypeLong")
            s = "long"
        case Application("idmTypeSingle")
            s = "single"
        case Application("idmTypeDouble")
			if PropDesc.GetState(Application("idmPropSupportsFPNumber")) then
				s = "FPNumber"
			else
	            s = "double"
			end if
        case Application("idmTypeDate")
            s = "date"
        case Application("idmTypeString")
            if ObjType = Application("idmObjTypeFolder") then
                s = "string"
            else
                s = "string:" + CStr(PropDesc.GetExtendedProperty("F_FIELDSIZE"))
            end if
        case Application("idmTypeBoolean")
            s = "boolean"
        case Application("idmTypeByte")
            s = "byte"
        case Application("idmTypeUnsignedShort")
            s = "unsigned short"
        case Application("idmTypeUnsignedLong")
            s = "unsigned long"
    end select
    ConvertToHints = s
End Function
%>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html">
<meta name="GENERATOR" content="Microsoft FrontPage 2.0">
<title>Property View</title>
</head>

<body bgcolor="#FFFFFF">

<table border="0" cellpadding="4" cellspacing="0">
    <tr>
        <td nowrap><% 'Display document or folder icon.
        if ObjType = Application("idmObjTypeDocument") then %><img src="images/ldoc.gif" width="34" height="39"><% else %><img
        src="images/lfolder.gif" width="38" height="39"><% end if %><font
        size="3"><strong><%= Ident %> : </strong></font>
        <% 'Display proper messages representing the state of the update or validation.
           if Update = "1" then
            if Status = "1" then %>
                <font color="#0000FF" size="4"><strong><em>
                ( Properties updated successfully. )
            <% elseif Status = "-1" then %>
                <font color="#AA0000" size="4"><strong><em>
                ( Properties update failed ! )
        <%  end if
           else
            if Status = "0" then %>
                <font color="#0000FF" size="4"><strong><em>
                ( Properties validated successfully. )
        <%  elseif Status = "-1" then %>
                <font color="#AA0000" size="4"><strong><em>
                ( Properties validation failed ! )
        <%  end if
           end if %>
        </em></strong></font>
        </td>
    </tr>
</table>

<%
'Get the users and groups collection from the Library object.
set Users = LibraryObj.Users
set Groups = LibraryObj.Groups

'Get the corresponding document or folder object as specified by ObjType and Ident.
set FObj = LibraryObj.GetObject(ObjType, Ident)

'Get the object's Permissions.
set Permissions = FObj.Permissions

'Get the object's Properties.
set Props = FObj.properties

if Status <> "" and Status <> "1" then
    'If update or validation failed, get the values submitted earlier and their validation status.
    SubmittedValues = Session("SubmittedValues")
    ValidationStatus = Session("ValidationStatus")
end if

'If the object is a folder, check to see whether the folder is a virtual folder.
IsVirtual = false
if ObjType = Application("idmObjTypeFolder") then
    if Props("F_ID") = 0 then
        IsVirtual = true
    end if
end if

'Check to see whether the user has permission to modify/update the properties or not.
CanModify = true
if ObjType = Application("idmObjTypeFolder") then
    CanModify = FObj.GetState(Application("idmFolderCanModify"))
elseif ObjType = Application("idmObjTypeDocument") then
    CanModify = FObj.GetState(Application("idmDocCanModifyProperties"))
end if


'Now, start dynamically generating the property form.
%>
<form name="property" action="propupdate.asp" method="POST">
<table border="0" cellpadding="0" cellspacing="1">
    <input type="hidden" name="IDMWeb_ObjType" value="<%= ObjType %>">
    <input type="hidden" name="IDMWeb_Ident" value="<%= Ident %>">

    <%
    'If the user can modify the properties, display some additional options like
    'ShowHints and Validation.
    if CanModify then %>
    <tr>
    <td>&nbsp;</td>
    <td colspan=4>
    <input type="checkbox" name="ShowHints" language="JavaScript" onclick="ShowPropertyHints()"
        <% if ShowHintsFlag then %>checked<% end if %>><font size=2>Show Property Hints</font>
    </td>
    <td align=right nowrap>
        <input type="radio" name="Validate" language="JavaScript" OnClick="ValidateProps()"><font size=2>Validate Now</font>
    </td>
    </tr>
    <% end if
    
    'Properties table headers %>
    <tr>
        <td align="center" width="30">&nbsp;</td>
        <td align="center" bgcolor="#EECCFF">&nbsp;</td>
        <td align="center" bgcolor="#EECCFF">&nbsp;</td>
        <td align="center" bgcolor="#EECCFF">&nbsp;</td>
        <td align="center" width="200" bgcolor="#EECCFF"><font
        size="3"><strong>Property</strong></font></td>
        <td align="center" width="200" bgcolor="#EECCFF"><font
        size="3"><strong>Value</strong></font></td>
        <td align="center" width="12" <% if ShowHintsFlag then %>bgcolor="#EECCFF"<% end if %>>&nbsp;</td>
        <td align="center" width="12">&nbsp;</td>
        <% 'If DebugFlag is set, display some additional headers.
        if DebugFlag then %>
        <% if ObjType = Application("idmObjTypeDocument") then %>
        <td align="center" width="100"><font size=1>Srch?&nbsp;</font></td>
        <td align="center" width="100"><font size=1>Sel?&nbsp;</font></td>
        <td align="center" width="100"><font size=1>Req?&nbsp;</font></td>
        <% end if %>
        <td align="center" width="100"><font size=1>Type&nbsp;</font></td>
        <td align="center" width="100"><font size=1>Size&nbsp;</font></td>
        <% if DebugFlag then %>
        <td align="center" width="100"><font size=1>Ext?&nbsp;</font></td>
        <td align="center" width="100"><font size=1>Name&nbsp;</font></td>
        <td align="center" width="100"><font size=1>Format&nbsp;</font></td>
        <% end if %>
        <% if ObjType = Application("idmObjTypeDocument") then %>
        <td align="center" width="100"><font size=1>U?&nbsp;</font></td>
        <td align="center" width="100"><font size=1>Mask&nbsp;</font></td>
        <% end if %>
        <td align="center" width="100"><font size=1>&nbsp;</font></td>
        </strong></font>
        <% end if %>
    </tr>

    <% 'Display the object's Permissions
    for i=1 to Permissions.Count
        set Permission = Permissions.Item(i)
        GranteeName = Permission.GranteeName %>
    <tr>
    <td valign=bottom align=right></td>
    <td valign=bottom align=right></td>
    <td valign=bottom align=left></td>
    <td valign=bottom align=left></td>
    <td valign=bottom><em><%= ConvertPermissionLabel(Permission.ID) %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</em></td>
    <td valign=bottom>
        <% 
        'If the user can modify/update permissions, then present a list of choices,
        'and pre-select the current setting.
        if CanModify then %>
        <select name="<%= Permission.ID %>" size="1">
            <option value="(ANYONE)" <% if GranteeName = "(ANYONE)" then %>selected<% end if %>>(ANYONE)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <option value="(NONE)" <% if GranteeName = "(NONE)" then %>selected<% end if %>>(NONE)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <% 'Add the Groups
               for each group in Groups
                Groupname = group.Name %>
            <option value="<%= Groupname %>" <% if GranteeName = Groupname then %>selected<% end if %>>(g)  <%= Groupname %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <% next %>
            <% 'Add the Users
               for each user in Users
                Username = user.Name %>
            <option value="<%= Username %>" <% if GranteeName = Username then %>selected<% end if %>>(u)  <%= Username %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <% next %>
        </select>
        <% else 'Just display the permissions as static text. %>
        <%= GranteeName %>
        <% end if %>
    </td>
    <td valign=bottom nowrap></td>
    <td valign=bottom nowrap></td>

    <% if DebugFlag then %>
    <td valign=bottom><em><%= Permission.Access %>&nbsp;</em></td>
    <td valign=bottom><em><%= Permission.GranteeName %>&nbsp;</em></td>
    <td valign=bottom><em><%= Permission.GranteeType %>&nbsp;</em></td>
    <td valign=bottom><em><%= Permission.ID %>&nbsp;</em></td>
    <% end if %>

    </tr>
    <% next %>
    
    <tr><td></td><td></td><td></td><td></td><td><hr></td><td><hr></td></tr>

    <% 'Display the object's Properties
    for i=1 to Props.Count
        'Enumerate through each Property, get the Property Description
        set Prop = Props(i)
        set PropDesc = Prop.PropertyDescription %>
    <tr>
    <td valign=bottom align=right></td>
    <td valign=bottom align=right>
    <% 'If the property is user defined, then display an iconic indication.
    IsSystem = PropDesc.GetExtendedProperty("F_ISSYSTEM")
    if IsSystem = 0 then %>
    <img src="images/user.gif" width="12" height="17">
    <% end if %>
    </td>

    <td valign=bottom align=left>
    <%
    if ObjType = Application("idmObjTypeDocument") then
        if PropDesc.GetExtendedProperty("F_ISSEARCHABLE") then
            'If the document property is an index key, then display an iconic indication.
            if PropDesc.getExtendedProperty("F_ISKEY") then %>
    <img src="images/key.gif" width="11" height="19">
    <%      end if
        end if
    end if %>
    </td>

    <td valign=bottom align=left>
    <% 
    IsReadOnly = PropDesc.GetExtendedProperty("F_ISREADONLY")
    if (not IsSystem) and (not IsReadOnly) then
        'If the property is required, then display an iconic indication.
        if PropDesc.GetExtendedProperty("F_ISREQUIRED") then %>
    <font color="#FF0000" size="5"><strong>*</strong></font>
    <%  end if
    end if %>
    </td>

    <td valign=bottom><em><%= Prop.Name %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</em></td>
    <td valign=bottom>
    <% value = ""
       if Status <> "" and Status <> "1" then
            'If the update or validation failed, then use the previously submitted value.
            value = SubmittedValues(i)
       end if
       if value = "" then
			'Use the object's property value.
			value = Prop.Value
			if not IsNull(value) then
				'Check for FPNumber
				if PropDesc.GetState(Application("idmPropSupportsFPNumber")) then
					value = Prop.FnFPNumber.ValueAsString
				end if
			end if
       end if

       if (not CanModify) or IsReadOnly then
        'If the user cannot modify/update the property value or the property is read-only,
        'then display the property value as static text.
        if IsNull(value) then %>
        <%= value %>
        <% else %>
        <%= Prop.FormatValue() %>
        <% end if
       elseif ObjType = Application("idmObjTypeFolder") and IsVirtual then
        'Virtual folder's property value cannot be modified, so display as static text
        'only. %>
        <%= value %>
    <% elseif Prop.Name = "F_RETENTBASE" then
        'Display the Retention Base property as a drop down list of choices. %>
        <select name="<%= Prop.Name %>" size="1">
            <option value="<%=Application("idmRetentionBaseCloseDate")%>" <% if CInt(value) = Application("idmRetentionBaseCloseDate") then %>selected<% end if %>>Closing Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <option value="<%=Application("idmRetentionBaseEntryDate")%>" <% if CInt(value) = Application("idmRetentionBaseEntryDate") then %>selected<% end if %>>Entry Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
        </select>
    <% elseif Prop.Name = "F_RETENTDISP" then
        'Display the Retention Disposition property as a drop down list of choices. %>
        <select name="<%= Prop.Name %>" size="1">
            <option value="<%=Application("idmRetentionDispositionArchive")%>" <% if CInt(value) = Application("idmRetentionDispositionArchive") then %>selected<% end if %>>Archive</option>
            <option value="<%=Application("idmRetentionDispositionDelete")%>" <% if CInt(value) = Application("idmRetentionDispositionDelete") then %>selected<% end if %>>Delete</option>
        </select>
    <% elseif Prop.Name = "F_CLOSED" and Props("F_RETENTBASE") then
        'If the Retention Base is based on Entry Date, then display the CLOSED property as
        'static text only.
        'Otherwise, it will fall into the next condition as boolean and displays a drop
        'down list of choices with True/False. %>
        <%= Prop.FormatValue() %>
    <% elseif PropDesc.TypeID = Application("idmTypeBoolean") then
        'If it's a boolean property, display a drop down list of choices with True/False. %>
        <select name="<%= Prop.Name %>" size="1">
            <option value="1" <% if value <> 0 then %>selected<% end if %>>True</option>
            <option value="0" <% if value = 0 then %>selected<% end if %>>False</option>
        </select>
    <% elseif PropDesc.GetState(Application("idmChoice")) then
        'If the property is a choice list, display the choices in a drop down list.
        set Choices = PropDesc.Choices %>
        <select name="<%= Prop.Name %>" size="1">
            <% if IsNull(value) then %>
                <option value="" selected>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <% end if %>
            <% for each Choice in Choices
                if value then %>
                <option value="<%= Choice.ID %>" <% if CLng(value) = Choice.ID then %>selected<% end if %>><%= Choice.Value %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
                <% else %>
                <option value="<%= Choice.ID %>"><%= Choice.Value %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <%  end if
               next %>
        </select>
    <% else 
        'Just display the property value using an editable field and limit the size
        'as necessary.
        if ObjType = Application("idmObjTypeDocument") then
            FieldSize = PropDesc.GetExtendedProperty("F_FIELDSIZE")
        else
            FieldSize = -1
        end if
    %>
        <input type="text" size="50" name="<%= Prop.Name %>"
            <% if FieldSize > 0 then %>
            maxlength=<%= FieldSize %>
            <% end if %>
            value="<%= value %>">
    <% end if %>
    </td>
    <td valign=bottom nowrap>
    <% if ShowHintsFlag and (not IsReadOnly) and (not PropDesc.GetState(Application("idmChoice"))) then
        'Display the property hint. %>
        <font size="2">(<%= ConvertToHints(ObjType, Prop) %>)</font>
    <% end if %>
    </td>
    <td valign=bottom nowrap>
    <% if Status = "-1" then
            'If the submitted value is invalid, indicate so with the original value.
            if ValidationStatus(i) = "-1" then %>
                <font color="#AA0000" size="2"><strong><=== <em>Invalid</em>, was <%= Prop.Value %></strong></font>
    <%      end if
       end if %>
    </td>

    <% 'If DebugFlag is set, display some additional information.
    if DebugFlag then %>
    <% if ObjType = Application("idmObjTypeDocument") then %>
    <td valign=bottom><em><%= PropDesc.GetExtendedProperty("F_ISSEARCHABLE") %>&nbsp;</em></td>
    <td valign=bottom><em><%= PropDesc.GetExtendedProperty("F_ISSELECTABLE") %>&nbsp;</em></td>
    <td valign=bottom><em><% if (not IsSystem) and (not IsReadOnly) then %><%= PropDesc.GetExtendedProperty("F_ISREQUIRED") %><% end if %>&nbsp;</em></td>
    <% end if %>
    <td valign=bottom><em><%= PropDesc.TypeID %>&nbsp;</em></td>
    <td valign=bottom><em><%= FieldSize %>&nbsp;</em></td>
    <td valign=bottom><em><%= PropDesc.GetState(Application("idmChoice")) %>&nbsp;</em></td>
    <td valign=bottom><em><% if PropDesc.GetState(Application("idmChoice")) then %><%= PropDesc.Name %><% end if %>&nbsp;</em></td>
    <td valign=bottom><em><% if PropDesc.GetState(Application("idmChoice")) then %><%= Prop.Value %><% else %><%= Prop.FormatValue %><% end if %>&nbsp;</em></td>
    <% if ObjType = Application("idmObjTypeDocument") then %>
    <td valign=bottom><em><% if (not IsSystem) and PropDesc.TypeID = Application("idmTypeString") then %><%= PropDesc.GetExtendedProperty("F_TREATASUPPER") %><% end if %>&nbsp;</em></td>
    <td valign=bottom><em><% if PropDesc.TypeID <> Application("idmTypeString") then %><%= PropDesc.GetExtendedProperty("F_DISPMASK") %><% end if %>&nbsp;</em></td>
    <% end if %>
    <td valign=bottom><em></em></td>
    <% end if %>

    </tr>
    <% next %>
</table>
<hr>
<table border="0" cellpadding="0" cellspacing="1">
    <tr>
    <td width="30" valign=bottom align=right></td>
    <td>
    <% 'If the user can modify/update properties, then show the submit/update button.
    if CanModify and (not IsVirtual) then %>
    <a href="javascript:Update()"><img alt="Update" src="images/update.gif" align=bottom border=0 width=41 height=41></a><em><strong>Update</strong></em>
    <% end if %>
    </td>
    </tr>
</table>

<input type="hidden" name="UpdateFlag" value="1">
</form>


<SCRIPT LANGUAGE="JavaScript">
<!--
// This function is called to refresh the property page whenever the Show
// Property Hints is toggled.
function ShowPropertyHints()
{
    document.property.UpdateFlag.value = "0";
    document.property.submit();
}

// This function is called to refresh the property page whenever the Validate Now
// button is clicked.
function ValidateProps()
{
    document.property.UpdateFlag.value = "0";
    document.property.submit();
}

// This function is called when the Update button is clicked.
function Update()
{
    document.property.UpdateFlag.value = "1";
    document.property.submit();
}
//-->
</SCRIPT>

&nbsp;<br>
</body>
</html>
